package com.aitaoxue.palx.db;

import com.aitaoxue.palx.db.RongyunDaoMaster.RongyunOpenHelper;

import android.content.Context;

public class RongyunDBManager {

	private static RongyunDBManager instance;
	private RongyunDaoMaster daoMaster;
	private RongyunDaoSession daoSession;

	public static RongyunDBManager getInstance(Context context) {
		if (instance == null) {
			synchronized (RongyunDBManager.class) {
				if (instance == null) {
					instance = new RongyunDBManager(context);
				}
			}
		}

		return instance;
	}

	private RongyunDBManager(Context context) {
		if (daoSession == null) {
			if (daoMaster == null) {
				RongyunOpenHelper dbHelper = new RongyunOpenHelper(context,
						context.getPackageName(), null);
				
				daoMaster = new RongyunDaoMaster(dbHelper.getWritableDatabase());
			}
			daoSession = daoMaster.newSession();
		}
	}

	public RongyunDaoMaster getDaoMaster() {
		return daoMaster;
	}

	public void setDaoMaster(RongyunDaoMaster daoMaster) {
		this.daoMaster = daoMaster;
	}

	public RongyunDaoSession getDaoSession() {
		return daoSession;
	}

	public void setDaoSession(RongyunDaoSession daoSession) {
		this.daoSession = daoSession;
	}

}
